package com.haoshuang.zhouzhoubang.utils

import android.content.Context
import android.view.View
import com.blankj.utilcode.util.ActivityUtils
import com.blankj.utilcode.util.AppUtils
import com.haoshuang.zhouzhoubang.ui.page.account.login.LoginActivity
import com.lnkj.jialubao.utils.AccountUtils
import com.lxj.xpopup.XPopup
import com.mufeng.libs.utils.startPage
import com.mufeng.libs.utils.view.click
import com.mufeng.libs.utils.view.clickWithTrigger
import com.mufeng.libs.utils.view.longClick

object EnvironmentUtils {
    fun changeEnvironment(view: View, context: Context) {

        view.clickWithTrigger {
            XPopup.Builder(context)
                .asConfirm(
                    "",
                    "当前为${if (AccountUtils.isTestEnvironment) "测试" else "正式"}环境, 是否要切换环境"
                ) {
                    AccountUtils.isTestEnvironment = !AccountUtils.isTestEnvironment
                    AccountUtils.logout()
                    Thread.sleep(500)
                    AppUtils.relaunchApp(true)
                }.show()
        }

    }

}